package com.approval.approvalapp.index.dbsx.zxhf.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.approval.approvalapp.R;
import com.approval.approvalapp.bean.WdbsBean;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by louyulin on 2019/5/8.
 */

public class WdbsAdapter extends RecyclerView.Adapter<WdbsAdapter.Holder> {
    List<WdbsBean> wdbsBeans;
    Context context;

    public void setWdbsBeans(List<WdbsBean> wdbsBeans) {
        this.wdbsBeans = wdbsBeans;
        notifyDataSetChanged();
    }

    @Override
    public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
        context = parent.getContext();
        View view = LayoutInflater.from(context).inflate(R.layout.item_wdbs, parent, false);
        Holder holder = new Holder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(Holder holder, int position) {
        holder.tv1.setText(wdbsBeans.get(position).getTitle());
        holder.tv2.setText(wdbsBeans.get(position).getType());
        holder.tv3.setText(wdbsBeans.get(position).getAdd_time());
    }

    @Override
    public int getItemCount() {
        if (wdbsBeans == null) {
            return 0;
        } else {
            return wdbsBeans.size();
        }
    }

    class Holder extends RecyclerView.ViewHolder {
        @Bind(R.id.tv1)
        TextView tv1;
        @Bind(R.id.tv2)
        TextView tv2;
        @Bind(R.id.tv3)
        TextView tv3;

        public Holder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
